$('.login form').on('submit', function(e) {
    // 阻止默认行为
    e.preventDefault();

    let data = $(this).serialize();
    $.ajax({
        type: 'POST',
        url: 'api/login',
        data: data,
        success: function(res) {
            console.log(res);
            if (res.status === 0) {
                layer.msg(res.message, {
                        timer: 2000,
                    },
                    function() {
                        location.href = ('./index.html');
                        localStorage.setItem('mytoken', res.mytoken)
                    }
                );
            }
        }
    })
})